package com.lyz.services.impl;

import com.lyz.models.Session;
import com.lyz.services.SessionService;

import java.util.concurrent.ConcurrentHashMap;

public class DefaultSessionService<T> extends SessionService<T> {

    private final ConcurrentHashMap<Object, Session<T>> sessionMap = new ConcurrentHashMap<>();

    @Override
    public void saveSession(Session<T> session) {
        sessionMap.put(session.getSessionId(), session);
    }

    @Override
    protected Session<T> findSession(Object sessionId) {
        return sessionMap.get(sessionId);
    }

    @Override
    protected void removeSession(Object sessionId) {
        sessionMap.remove(sessionId);
    }

    @Override
    public boolean check(String permission) {
        return true;
    }
}
